<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<html>
<head>
    <title>delete</title>
</head>
<body>
<%
    int curpage = 1;
    if (request.getParameter("page") != null) {
        String pg = request.getParameter("page");
        curpage = Integer.parseInt(pg);
    }
    String name = "";
    String number = "";
    String type = "";
    String vendor = "";
    String date = "";
    String time = "";
    String afterSales = "";
    String phone = "";
    String id = request.getParameter("id");

    if (request.getParameter("name") != null) name = request.getParameter("name");
    if (request.getParameter("number") != null) number = request.getParameter("number");
    if (request.getParameter("type") != null) type = request.getParameter("type");
    if (request.getParameter("vendor") != null) vendor = request.getParameter("vendor");
    if (request.getParameter("date") != null) date = request.getParameter("date");
    if (request.getParameter("inboundTime") != null) time = request.getParameter("time");
    if (request.getParameter("afterSales") != null) afterSales = request.getParameter("afterSales");
    if (request.getParameter("phone") != null) phone = request.getParameter("phone");

    Connection conn = (Connection)session.getAttribute("Connection");
    String sql = "delete from device where id=" + id;
    PreparedStatement preparedStatement = conn.prepareStatement(sql);
    int res = preparedStatement.executeUpdate();
    System.out.print(sql);
    if (res > 0) {
        out.println("删除数据成功");
        request.getRequestDispatcher("device_list.jsp").forward(request, response);
    } else {
        out.println("删除数据失败");
        response.setHeader("refresh", "3;device_list.jsp");
    }

%>
</body>
</html>
